package com.cskaoyan;

import com.cskaoyan.connectionpool.MyConnectionPoolV1;
import com.cskaoyan.connectionpool.MyConnectionPoolV3;
import com.cskaoyan.connectionpool.opensource.C3p0Utils;
import com.cskaoyan.connectionpool.opensource.DBCPUtils;
import com.cskaoyan.connectionpool.opensource.DruidUtils;
import com.cskaoyan.util.JDBCUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2022/07/01 11:11
 *
 * @author ciggar
 */
public class Main {


    public static void main(String[] args) throws SQLException {


        // 从连接池中获取连接
        Connection connection = DruidUtils.getConnection();

        Statement statement = connection.createStatement();

        ResultSet resultSet = statement.executeQuery("select * from account");

        while (resultSet.next()) {

            int id = resultSet.getInt("id");
            String name = resultSet.getString("name");
            System.out.println("Id:" + id + ", name:" + name);
        }
        // 关闭资源
        JDBCUtils.releaseSources(connection,statement,resultSet);


    }
}
